package C6;

import java.util.Arrays;

public class SortTest {
    public static void main(String[] args) {
        Student[] students = new Student[4];
        Student s1 = new Student("张三",22,"1001",56.5);
        Student s2 = new Student("李四",21,"1002",66.5);
        Student s3 = new Student("二狗",20,"1003",50.5);
        Student s4 = new Student("富贵",19,"1004",76);
        //通过索引
        students[0] = s1;
        students[1] = s2;
        students[2] = s3;
        students[3] = s4;
        try {
            students[2] = null;
            students[2].getAge();
        }catch (NullPointerException e){
            System.out.println("没找到");
        }finally {
            System.out.println("Success!");
        }

//        //排序
//        Arrays.sort(students);
//        //s1 s2
//        s1.compareTo(s2); //this -》s1   o-》s2
//        s2.compareTo(s1);
//        for (Student s:students
//             ) {
//            System.out.println(s.toString());
//        }
    }
}
